package group2assignone.ucm.customer;

import group2assignone.view.LoadingView;
import group2assignone.view.MainView;

/**
 *
 * @author Flick
 */
public class LoginCustomerProxy extends UCLoginCustomer {

    private boolean waiting = true;
    private UCLoginCustomer ucl;
    private static final int SLEEP = 7000;

    public LoginCustomerProxy(MainView view) {
        ucl = new UCLoginCustomer(view);
    }

    @Override
    public void run() {
        Thread t = new Thread(new LoginThread());
        t.start();
        Thread t2 = new Thread(new AnimateThread());
        t2.start();
    }

    public class LoginThread implements Runnable {

        public void run() {
            try {
                Thread.sleep(SLEEP);
            } catch (InterruptedException ex) {
            }
            ucl.run();
            waiting = false;
        }
    }

    public class AnimateThread implements Runnable {

        public void run() {
            LoadingView ldView = new LoadingView();
            ldView.go();
            while (waiting) {
                ldView.animate();
            }
            ldView.dispose();
        }
    }
}
